package com.hou.netty.serial;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.util.ReferenceCountUtil;

//客户端处理类,有序列化编解码,可以直接接受对象
public class ClientHandler extends SimpleChannelInboundHandler<Result> {
    @Override
    protected void channelRead0(ChannelHandlerContext channelHandlerContext, Result result) throws Exception {
        System.out.println("客户端接受到结果:" + result.getMemo());
        ReferenceCountUtil.release(result);//没有写操作一定要释放
    }

    @Override
    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
        ctx.close();
    }
}
